<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>JQueryDom操作</title>
		<link rel="stylesheet" type="text/css" href="css/txt.css" />
		<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<div>
			<div id="mydiv"></div>
		</div>

	</body>

	<script type="text/javascript">
		$(function() {
			// 增加一个元素<h2>www.baidu.com</h2>
//			$(mydiv).append("<h2>www.baidu.com</h2>");
			var eml = $("<h2>www.baidu.com</h2>");
//			$("#mydiv").append(eml);
			var flag = false;
			$(mydiv).append(function(){
				
				if(flag){
					return "<h2>www.baidu.com</h2>";
				}else{
					return "<h2>www.mldn.cn</h2>";
				}
				
			});
		});
	</script>

</html>